package iphoneBackupScanner.common;

public enum Categorie {

	AppDomain("AppDomain-",Directory.Application), 
	
	HomeDomain("HomeDomain", Directory.Library),
	
	MediaDomain("MediaDomain", Directory.Media),
	
	MobileDeviceDomain("MobileDeviceDomain", Directory.Default), 
	
	KeychainDomain(	"KeychainDomain", Directory.Default),
	
	WirelessDomain("WirelessDomain", Directory.Library),
	
	RootDomain("RootDomain", Directory.Library),
	
	SystemPreferencesDomain("SystemPreferencesDomain", Directory.SystemConfiguration),
	
	ManagedPreferencesDomain("ManagedPreferencesDomain", Directory.Default);
	
	
	private final String identifier;
	private final Directory directory;

	Categorie(final String identifier, final Directory directory) {
		this.identifier = identifier;
		this.directory = directory;
	}

	public static Categorie parseCategorie(final String str) {

		Categorie domain = null;

		for (Categorie d : values()) {
			if (str.length() >= d.identifier.length())
				if (str.substring(0, d.identifier.length())
						.equals(d.identifier))
					domain = d;
		}

		if (domain == null) {
			throw new IllegalArgumentException();
		}

		return domain;

	}
	
	public String getDirectory(){
		return directory.toString();
		
	}
	@Override
	public String toString() {
		return directory.toString();
	}
	
}
